package com.financing.platform.web;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.financing.platform.dto.FriendshipLinkDTO;
import com.financing.platform.service.IFriendshipLinkService;
import com.financing.platform.util.StringUtil;

@Controller
public class FriendshipLinkAction extends BaseAction{
	
	@Autowired
	IFriendshipLinkService friendshipLinkService;
	
	@RequestMapping("/queryFriendshipLinkList.shtml")
	public ModelAndView queryList(HttpServletRequest request,
			HttpServletResponse response,FriendshipLinkDTO friendshipLinkDTO) {
			Map<String,Object> faUserMap = new HashMap<String,Object>();
			faUserMap.put("list", friendshipLinkService.queryList(friendshipLinkDTO));
			return new ModelAndView("friendshipLinkList",faUserMap);
	}
	
	@RequestMapping("/addFriendshipLink.shtml")
	public String add(HttpServletRequest request,
			HttpServletResponse response,FriendshipLinkDTO friendshipLinkDTO) {
			int result = friendshipLinkService.add(friendshipLinkDTO);
			return "redirect:queryFriendshipLinkList.shtml";
				
	}
	
	@RequestMapping("/updateFriendshipLink.shtml")
	public String update(HttpServletRequest request,
			HttpServletResponse response,FriendshipLinkDTO friendshipLinkDTO) {
			friendshipLinkService.update(friendshipLinkDTO);
			return "redirect:queryFriendshipLinkList.shtml";
				
	}
	
	@RequestMapping("/toAddFriendshipLink.shtml")
	public ModelAndView toAdd(HttpServletRequest request,
			HttpServletResponse response) {
			return new ModelAndView("addFriendshipLink");
				
	}
	
	@RequestMapping("/friendshipLinkDetail.shtml")
	public ModelAndView detail(HttpServletRequest request,
			HttpServletResponse response, FriendshipLinkDTO friendshipLinkDTO) {
		Map<String, Object> dtoMap = new HashMap<String, Object>();
		dtoMap.put("dto", friendshipLinkService.get(friendshipLinkDTO.getId()));

		return new ModelAndView("updateFriendshipLink", dtoMap);

	}
	
	
	@RequestMapping("/deleteFriendshipLink.shtml")
	public String delete(HttpServletRequest request,
			HttpServletResponse response,FriendshipLinkDTO friendshipLinkDTO) {
			friendshipLinkService.delete(friendshipLinkDTO.getId());
			return "redirect:queryFriendshipLinkList.shtml";
				
	}
	
}
